package org.weasel.business;

import java.util.ArrayList;

public class Company {
	private String name;
	private ArrayList<Project> projects;
	private ArrayList<Developer> developers;
	
	public Company(String name, ArrayList<Project> projects, ArrayList<Developer> developers) {
		this.name = name;
		if (projects != null)
			this.projects = projects;
		else
			this.projects = new ArrayList<Project>();
		
		if (developers != null)
			this.developers = developers;
		else
			this.developers = new ArrayList<Developer>();
	}


	public ArrayList<Developer> getDevelopers() {
		return developers;
	}


	public void setDevelopers(ArrayList<Developer> developers) {
		this.developers = developers;
	}


	public String getName() {
		return name;
	}


	public void setName(String name) {
		this.name = name;
	}


	public ArrayList<Project> getProjects() {
		return projects;
	}


	public void setProjects(ArrayList<Project> projects) {
		this.projects = projects;
	}

	public void addDeveloper(Developer developer){
		developers.add(developer);
	}
	
	public void removeDeveloper(String id){
		Developer d;
		for (int i =0; i<developers.size(); i++){
			d = developers.get(i);
			if (d.getId().equals(id)){
				developers.remove(i);
				return;
			}
		}
	}
	
	public Developer getDeveloper(String id){
		for (Developer developer : developers) {
			if (developer.getId().equals(id))
				return developer;			
		}
		return null;
	}
	
	public void addProject(Project project){
		projects.add(project);
	}
	
	public void removeProject(String id){
		Project p;
		for (int i = 0; i < projects.size(); i++) {
			p = projects.get(i);
			if (p.getId().equals(id)){
				projects.remove(i);
				return;
			}
			
		}
	}

	public Project getProject(String id){
		for (Project project : projects) {
			if (project.getId().equals(id))
				return project;
		}
		return null;
	}

	
}
